﻿
var AddProduct = {
    ajaxBtnUrl: '',
    ajaxSwfUrl: '',
    ajaxImgUrl: '',
    ajaxPdfUrl: '',
    ajaxFlashUrl: '',
    url: '',
    listUrl: '',
    popupSubmit: function () {
        var parameters = { photoArray: JSON.stringify(photoArrayList) };
        //var pdfUrl = { pdfUrl: JSON.stringify(pdfUrl) };
        var editorContent = { editorDes: editor.getContent() };
        Object.extend(parameters, $("form1").serialize(true));
        Object.extend(parameters, editorContent);

        new Ajax.Request(AddProduct.url, {
            method: 'post',
            parameters: parameters,
            onSuccess: function (transport) {
                if (transport.responseText != "true") {
                    alert(transport.responseText);
                }
                else {
                    window.location.href = AddProduct.listUrl;
                }
            }
        });
    },
    seriesSubmit: function () {
        var parameters = { photoArray: JSON.stringify(photoArrayList) };;
        Object.extend(parameters, $("form1").serialize(true));

        new Ajax.Request(AddProduct.url, {
            method: 'post',
            parameters: parameters,
            onSuccess: function (transport) {
                if (transport.responseText != "true") {
                    alert(transport.responseText);
                }
                else {
                    window.location.href = AddProduct.listUrl;
                }
            }
        });
    }
}

function CreateImgItem(photoJson) {
    var newDiv = document.createElement("div");
    newDiv.className = "uploadpic";
    var newImg = document.createElement("img");
    newImg.setAttribute("width", "40");
    newImg.setAttribute("height", "20");
    newImg.src = photoJson.ImageUrl;
    var newDel = document.createElement("div");
    newDel.innerHTML = "删除";
    newDel.setAttribute("id", photoJson.Name);
    newDel.onclick = function () {
        photoArrayList = photoArrayList.without(photoJson);
        $(photoJson.Name).up().remove();
        swfImg.setFileUploadLimit(parseInt(swfImg.settings.file_upload_limit) + 1);
    };
    newDiv.appendChild(newImg);
    newDiv.appendChild(newDel);
    document.getElementById("thumbnails").appendChild(newDiv);
}








